import {SETMOVIELIST} from "../mutation_types"
import axios from "axios";
const state = {
  movieList: [],
};

// const state = JSON.parse(localStorage.getItem("movie_vuex")) || initState
const mutations = {
  [SETMOVIELIST](state, payload) {
    state.movieList = payload.movieList;
    // localStorage.setItem("movie_vuex",JSON.stringify(state))
    
  },
};
const actions = {
  async getMovieList({ commit }) {
    const re = await axios.get(
      `https://pcw-api.iqiyi.com/search/recommend/list?channel_id=1&data_type=1&mode=11&page_id=2&ret_num=48&session=b9fd987164f6aa47fad266f57dffaa6a`
    );
    commit("setMovieList", { movieList: re.data.data.list });
  },
};
const getters = {};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
};
